Use case: Read and write operations ¶
Sequence diagram ¶
Code snippet ¶
|
HAL1 |
HAL2 |
|---|---|
/* - */
// Write data to the SRAM memory
HAL_SRAM_Write_8b(&hsram,
(uint32_t *)(target_address),
data_to_write,
BufferSize
);
// Read data from the SRAM memory
HAL_SRAM_Read_8b(&hsram,
(uint32_t *)(target_address),
data_read,
BufferSize
);
|
uint32_t size;
uint8_t *psramaddress = (uint8_t *)target_address;
uint8_t *psrcbuff = data_to_write;
uint8_t *pdestbuff = data_read;
/* Write data to memory */
for (size = BufferSize; size != 0U; size--)
{
*psramaddress = *psrcbuff;
psrcbuff++;
psramaddress++;
}
/* Read data from memory */
for (size = BufferSize; size != 0U; size--)
{
*pdestbuff = *psramaddress;
pdestbuff++;
psramaddress++;
}
|
Key changes ¶
In HAL2, the SRAM driver only configures FMC; there are no dedicated SRAM read/write APIs.
Once FMC is configured, SRAM is memory-mapped and accessed by direct CPU reads/writes.

